<?php
/**
 * CK 开发框架
 * User: Clake
 * Date: 15/6/18
 * Time: 01:35
 */

namespace CK\Cache;


class Cache {

    private static $_instance = [];

//    private static $_conf = [
//        'type'=>'memcached', // memcached | file
//        'conf'=>[
//            'servers'=>[['host'=>'127.0.0.1','port'=>11211]]
//        ]
//    ];

    private static $_conf = [];

    const MEMCACHED = 'memcached';
    const FILE = 'filecached';
    const REDIS = 'redis';
    /**
     * 初始化缓存类
     * @return static
     */
    public static function inst() {
        $conf = C('cache');
        if ($conf) {
            self::$_conf = $conf;
        }

        if (self::$_conf && is_array(self::$_conf)) {
            $name = self::$_conf['type'];
            if (!isset(self::$_instance[$name])) {
                $class = "CK\\Cache\\".ucfirst($name);
                self::$_instance[$name] = new $class(self::$_conf['conf']);
            }
            return self::$_instance[$name];
        } else {
            return null;
        }
    }

    public function get($key){
        return '';
    }
    public function set($key,$value,$expire=0){
        return true;
    }
    public function delete($key,$timeout=0){
        return true;
    }
}